<template>
  <div  v-transfer-dom>
       <popup v-model="showPopup" height="100%" is-transparent>
        <div class="select_popup_div">
            <group class="select_group"  v-if="showType=='cehui'"  title="请选择撤回原因" gutter="0">
              <radio   @on-change="changeReason" :options="reasonCehuiList"></radio>
            </group>
            <group class="select_group" v-if="showType=='cexiao'" title="请选择撤消原因" gutter="0">
              <radio   @on-change="changeReason" :options="reasonCexiaoList"></radio>
            </group>
            <div class="select_button">
                <x-button type="primary" @click.native="doCancel" class="dskt_btn">返回</x-button>
            </div>
        </div>
      </popup>
  
  </div>
</template>

<script>
import baseService from '../shared/service/baseService'

import { PopupHeader, Popup, TransferDom, Group, XSwitch, Radio } from 'vux'

export default {
  components: {
    PopupHeader,
    Popup,
    Group,
    XSwitch,
    Radio,
  },
  name: "selectReason",
  props: ["okText","noText"], /* okEvent 文件上传完成事件 */
  data() {
    return {
      reasonCehuiList:[],
      reasonCexiaoList:[],
      showPopup:false,
      showType:'cexiao',
      dataId:""
    };
  },
  created() {
    this.doGetReasonList();
  },
  methods: {
     doGetReasonList() {
        baseService.getReasonList().then((res)=>{
          var data = res.data;
          var cehuiList =[];
          var cexiaoList =[];
          for (let i = 0; i < data.length; i++) {
            const element = data[i];
            element.key=element.id;
            element.value = element.reason;
            if(element.recallType==1){
              cexiaoList.push(element);
            }else if(element.recallType==2){
              cehuiList.push(element);
            }
          }
          this.reasonCexiaoList=cexiaoList;
          this.reasonCehuiList=cehuiList;
        });
    },
    changeReason(value, label) {
      this.$emit('okEvent',this.dataId,label,this.showType);
      this.showPopup=false;
    },
    doCancel() {
      this.showPopup=false;
    },
    showCexiao(id) {
      //cehui cexiao
      this.showType='cexiao';
      this.showPopup=true;
      this.dataId=id;
    },
    showCehui(id) {
      //cehui cexiao
      this.showType='cehui';
      this.showPopup=true;
      this.dataId=id;
    }
  }
};
</script>

<style scoped>

</style>